function fn(star, end) {
  if (star === end) {
    return star
  }
  if (star < end) return star + fn(star + 1, end)
  if (star > end) return star + fn(star - 1, end)
}
console.log(fn(1, 5))
